﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using PMS.Application.ProjectApp;
using PMS.Domain.AggregatesModel.ProjectAggregate;

namespace PMS.Web.Controllers
{
    public class ProjectController : BaseController
    {
        private readonly IProjectService _projectService;

        public ProjectController(IProjectService projectService)
        {
            _projectService = projectService;
        }


        public async Task<IActionResult> CreateAsync()
        {
            var project = new Project("测试项目", "东电的项目", UserIdentity.Name, UserIdentity.UserId, DateTime.Now, DateTime.Now.AddDays(10));

            await _projectService.CreateProjectAsync(project);

            return Ok("创建成功");
        }

        public async Task<IActionResult> AddContributorAsync()
        {
                   
             await  _projectService.AddContributorAsync(1, new List<ProjectContributor> { new ProjectContributor(3, "测试用户4") ,new ProjectContributor(4, "测试用户4") });
            return Ok("创建项目参与者成功");
        }
    }
}